<?php

namespace App\Admin\Controllers;

use App\AdminPermission;

class PermissionController extends Controller
{

    //权限列表页面
    public function index()
    {
        $permissions = AdminPermission::paginate(10);
        return view('admin.permission.index', compact('permissions'));
    }

    //创建权限
    public function create()
    {
        return view('admin.permission.add');
    }

    //创建权限行为
    public function store()
    {
        $this->validate(request(), [
            'name' => 'required|min:3',
            'description' => 'required|min:3',
        ]);

        $data = [
            'name' => request('name'),
            'description' => request('description')
        ];

        AdminPermission::create($data);

        return redirect('/admin/permissions');

    }


}